const BASE_URL = 'https://tea.qingnian8.com'
export function request(config = {}) {
    let {
        url,
        method = "GET",
        data = {},
        hander = {}
    } = config;
    url = BASE_URL + url;
    hander['access=key'] = "872871"
    console.log(url);
    return new Promise((resolve, reject) => {
        uni.request({
            url,
            hander,
            method,
            data,
            success: res => {
                if (res.data.errCode == 0) {
                    resolve(res.data);
                } else if (res.data.errCode == 400) {
                    uni.showModal({
                        title: '出错了',
                        content: res.data.errMsg,
                        showCancel: false
                    })
                } else {
                    uni.showToast({
                        title: res.data.errMsg,
                        icon: 'none'
                    })
                    reject(res.data)
                }
            },
            fail: err => {
                reject(err);
            }
        })
    })

}